package pingji.dao.login.impl;

import lombok.extern.java.Log;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;
import pingji.controller.login.LoginObject;
import pingji.dao.login.LoginDao;
import pingji.dao.mapper.UserMapper;
import pingji.pojo.User;
@Log
@Repository
public class LoginDaoImpl implements LoginDao {
    @Autowired
    UserMapper mapper;
    @Override
    public int login(LoginObject lo) {
        User user = mapper.selectByName(lo.getUsername());
        if(user==null){
            return -1;
        }
        log.info(user.toString());
        if(lo.getUsername().equals(user.getName())&&lo.getPassword().equals(user.getPassword())){
            return user.getId();
        }
        return -1;
    }
}
